package hn.cch.template;

import hn.cch.constant.JdbcConstant;
import hn.cch.dynamic.DynamicAnnotation;
import hn.cch.entity.Master;
import hn.cch.entity.Replica;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


@Component
public class ReplicaTemplate extends BaseTemplate<Replica> {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @DynamicAnnotation(name = JdbcConstant.REPLICA)
    public List<Replica> getAll() {

        String sql = " select * from tbl_replica ";
        List<Replica> all = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Replica.class));
        return all;

    }

}
